<?php
/**
*
*	求助投诉 @zairwolf
*/
if(!defined('IN_ACP')) exit('Access Denied');


//回复投诉
if($action == 'reply') {
	$id=_get('id');
	if(empty($id) || !ris_int($id)) b('无此记录');

	$row = db_r("select * from rd8_help where id='$id' and active=1");
	if(!$row) b('无此记录');
	$row=html_show($row);

	$tpl = new T($ptype.'_'.$pfile.'_'.$action);
	$tpl->assign($row);
	$tpl->output();
}

//回复投诉提交
if($action == 'update') {
	$id=_post('id');
	$reply=_post('reply');
	if(empty($id) || !ris_int($id) || !db_r("select id from rd8_help where id='$id'")) b('记录错误');
	if(empty($reply)) b('请填写回复内容');

	db_q("update rd8_help set reply='$reply',replytime=".TIMESTAMP." where id='$id'");

	j("?ptype=$ptype&pfile=$pfile", '回复成功');
}

//回复删除
if($action == 'delete') {
	$ids=_get_post('ids');
	if(!$ids) b('无删除对象');
	if(count($ids)>20) b('删除条目过多');

	db_q("update rd8_help set active=0 where id in ('".implode("','",$ids)."')");

	j("?ptype=$ptype&pfile=$pfile", '删除成功');

}

//用户列表
if(!$action){
	$total=db_r("select count(*) as totalnum from rd8_help where active=1");
	$pagelink=page($total['totalnum'],20,0,0);
	$list=db_rows("select * from rd8_help where active=1 order by dateline desc $pagelink[limit]");

	$tpl = new T($ptype.'_'.$pfile);
	$tpl->assign(array(
		'list'   => html_show($list),
		'pagelink' => $pagelink['output'],
	));
	$tpl->output();
}

